﻿package mortal.game.view.heroArena.view
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import extend.language.*;
    import flash.events.*;
    import flash.geom.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.common.swfPlayer.*;
    import mortal.component.gconst.*;
    import mortal.game.control.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.arena.util.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.palyer.util.*;

    public class HeroArenaRewardTakeSpr extends GSprite
    {
        private var _rewardName:GTextFiled;
        private var _rewardItem:BaseItem;
        private var _rewardInfo:GTextFiled;
        private var _takeRewardBtn:GButton;
        private var _lookRuleLink:GTextFiled;
        private var _vipAddition:GTextFiled;
        private var _tipImg:GImageBitmap;
        private var _tipTxt:GTextFiled;
        private var _arrow:SWFPlayer;
        private var _rewardData:SArenaPlayerReward;
        private var _index:int;
        private var _isAddArrow:Boolean;

        public function HeroArenaRewardTakeSpr()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.ArenaTakeRewardBg, 0, 0, this));
            this._rewardName = UIFactory.gTextField("", 0, 10, 200, 20, this, GlobalStyle.textFormatLv.center());
            this._rewardItem = UICompomentPool.getUICompoment(BaseItem);
            this._rewardItem.setItemStyle(66, "", 0, 0);
            this._rewardItem.x = 23;
            this._rewardItem.y = 44;
            this.addChild(this._rewardItem);
            this._rewardInfo = UIFactory.gTextField("", 127 - 23, 42, 70, 25, this, GlobalStyle.textFormatHuang.setSize(14));
            this._takeRewardBtn = UIFactory.gButton(Language.getString(41571), 119, 89, 48 + 3, 20, this);
            this._takeRewardBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this._lookRuleLink = UIFactory.gTextField("", 74, 126, 82, 20, this, GlobalStyle.textFormatHuang2);
            this._lookRuleLink.htmlText = HTMLUtil.addLink(Language.getString(41572), GlobalStyle.colorHuang2);
            this._lookRuleLink.configEventListener(MouseEvent.CLICK, this.onLinkClickHandler);
            this._lookRuleLink.configEventListener(MouseEvent.MOUSE_OVER, this.onOverHandler);
            this._lookRuleLink.configEventListener(MouseEvent.MOUSE_OUT, this.onOutHandler);
            var _loc_1:* = GlobalStyle.textFormatHui;
            _loc_1.size = 22;
            _loc_1.bold = true;
            this._vipAddition = UIFactory.gTextField(Language.getString(41573), 99, 69 - 2, 112, 20, this, GlobalStyle.textFormatLv);
            this._vipAddition.visible = false;
            this._tipImg = UIFactory.gImageBitmap("", 100 + 10, 52 - 8, this);
            this._tipTxt = UIFactory.gTextField("", 100 + 10, 52 - 12, 86, 50, this, GlobalStyle.textFormatPutong.setSize(16));
            this._tipTxt.multiline = true;
            this._tipTxt.wordWrap = true;
            this._arrow = UICompomentPool.getUICompoment(SWFPlayer);
            return;
        }// end function

        private function onClickHandler(event:MouseEvent) : void
        {
            GameProxy.copy.getArenaReward(ECopyType._ECopyTypeArena2v2, this._rewardData.type);
            this.isTakeBtnAvailable = false;
            var _loc_2:* = this._rewardItem.localToGlobal(new Point());
            FlyToNavbarTool.flyToBackPack(this._rewardItem.bitmapdata, _loc_2);
            return;
        }// end function

        public function set data(param1:SArenaPlayerReward) : void
        {
            var _loc_2:int = 0;
            var _loc_3:Array = null;
            var _loc_4:Array = null;
            var _loc_5:int = 0;
            var _loc_6:ItemExInfo = null;
            var _loc_7:int = 0;
            this._rewardData = param1;
            switch(this._index)
            {
                case 0:
                {
                    if (_loc_5 != 0)
                    {
                    }
                    break;
                }
                case 1:
                {
                    if (_loc_3 && _loc_3.length > 0)
                    {
                        if (!this._rewardItem.itemData.extInfo)
                        {
                            if (this._rewardData)
                            {
                            }
                        }
                    }
                    break;
                }
                case 2:
                {
                    if (_loc_4 && _loc_4.length > 0)
                    {
                        if (!this._rewardItem.itemData.extInfo)
                        {
                            if (this._rewardData)
                            {
                            }
                        }
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            switch(param1.state)
            {
                case EArenaRewardGetState._EStateNotGet:
                {
                    if (_loc_7 > 0 && this._index == 0)
                    {
                    }
                    else
                    {
                    }
                    break;
                }
                case EArenaRewardGetState._EStateHadGet:
                {
                    break;
                }
                case EArenaRewardGetState._EStateOverdue:
                {
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function set isTakeBtnAvailable(param1:Boolean) : void
        {
            if (param1)
            {
                this._takeRewardBtn.filters = [];
                this._takeRewardBtn.mouseEnabled = true;
                EffectManager.glowFilterReg(this._takeRewardBtn);
                this.addArrow();
            }
            else
            {
                this._takeRewardBtn.filters = [FilterConst.colorFilter2];
                this._takeRewardBtn.mouseEnabled = false;
                EffectManager.glowFilterUnReg(this._takeRewardBtn);
                this.removeArrow();
            }
            return;
        }// end function

        private function set tipImgVisible(param1:Boolean) : void
        {
            switch(this._index)
            {
                case 0:
                {
                    break;
                }
                case 1:
                {
                    break;
                }
                case 2:
                {
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function onLinkClickHandler(event:MouseEvent) : void
        {
            if (this._rewardData)
            {
                HeroArenaSettleRuleWin.instance.openPanelByTab((this._rewardData.type - 1));
            }
            return;
        }// end function

        private function onOverHandler(event:MouseEvent) : void
        {
            CursorManager.showCursor(CursorManager.BUTTON);
            return;
        }// end function

        private function onOutHandler(event:MouseEvent) : void
        {
            CursorManager.hideFromButton();
            return;
        }// end function

        private function addArrow() : void
        {
            if (!this._isAddArrow)
            {
                FashionUtil.addArrow(this._arrow, this, this._takeRewardBtn.x - 10, this._takeRewardBtn.y + 18 - 4);
                this._isAddArrow = true;
            }
            return;
        }// end function

        private function removeArrow() : void
        {
            if (this._isAddArrow)
            {
                FashionUtil.removeArrow(this._arrow);
                this._isAddArrow = false;
            }
            return;
        }// end function

        public function get rewardData() : SArenaPlayerReward
        {
            return this._rewardData;
        }// end function

        public function set index(param1:int) : void
        {
            this._index = param1;
            switch(this._index)
            {
                case 0:
                {
                    this._rewardName.text = Language.getString(41579);
                    break;
                }
                case 1:
                {
                    this._rewardName.text = Language.getString(41580);
                    break;
                }
                case 2:
                {
                    this._rewardName.text = Language.getString(41581);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._rewardName.dispose();
            this._rewardName = null;
            this._rewardItem.dispose();
            this._rewardItem = null;
            this._rewardInfo.dispose();
            this._rewardInfo = null;
            this._takeRewardBtn.dispose();
            this._takeRewardBtn = null;
            this._lookRuleLink.dispose();
            this._lookRuleLink = null;
            this._vipAddition.dispose();
            this._vipAddition = null;
            this._tipImg.dispose();
            this._tipImg = null;
            this._arrow.dispose();
            this._arrow = null;
            this._tipTxt.dispose();
            this._tipTxt = null;
            this._rewardData = null;
            this._index = 0;
            this._isAddArrow = false;
            return;
        }// end function

    }
}
